// pages/myaudioList/myaudioList.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        myaudios:[

        ],
        mydir:'',
        currid:1
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        console.log(options)
        this.setData({
            mydir:options.mydir
        })
        let newList = []
        for(var i=1;i<=30;i++){
            let item = {
                id:i,
                name:"audio"+String(i)
            }
            newList.push(item)
        }
        this.setData({
            myaudios:newList
        })
    },

    //顺序播放
    gotoLine:function(e){
        console.log(e)
        let id = e.target.dataset.id
        this.setData({
            currid:id
        })
        let mydir = this.data.mydir
        wx.getBackgroundAudioManager().title = this.data.mydir
        // 'https://www.syrkitty.com/music/audio/' + mydir + "/" + id + ".mp3",

        wx.getBackgroundAudioManager().title = this.data.currid
        wx.getBackgroundAudioManager().src = 'https://www.syrkitty.com/music/audio/' + mydir + "/" + this.data.currid + ".mp3"

        wx.getBackgroundAudioManager().onEnded(()=>{
            // console.log("getBackgroundAudioManager................")
            this.setData({
                currid:this.data.currid +1
            })
            wx.getBackgroundAudioManager().title = this.data.currid
            wx.getBackgroundAudioManager().src = 'https://www.syrkitty.com/music/audio/' + mydir + "/" + this.data.currid + ".mp3"
           
        })
    },
    gotoDetail:function(e){
        wx.getBackgroundAudioManager().stop()
        let id = e.target.dataset.id
        let name = e.target.dataset.name
        wx.navigateTo({
          url: '../myaudioDetail/myaudioDetail?id='+id + "&name=" + name + "&mydir=" + this.data.mydir,
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})